﻿CREATE PROCEDURE [UserProfiles_update]
	@P_1 Int,
	@P_2 NVarChar(100),
	@P_3 NVarChar(50),
	@P_4 NVarChar(50),
	@P_5 DateTime,
	@P_6 Bit,
	@P_7 Int,
	@P_8 Float,
	@P_9 NVarChar(500),
	@P_10 Float,
	@P_11 Float,
	@P_12 Float,
	@P_13 Float,
	@P_14 Float,
	@P_15 Int,
	@P_16 Float,
	@P_17 Int,
	@P_18 Int,
	@P_19 Int,
	@P_20 Float,
	@P_21 DateTime,
	@P_22 DateTime,
	@P_23 Int,
	@sync_force_write Int,
	@sync_min_timestamp BigInt,
	@sync_row_count Int OUTPUT
AS
BEGIN
SET @sync_row_count = 0; UPDATE [UserProfiles] SET [Name] = @P_2, [FirstName] = @P_3, [LastName] = @P_4, [Birthday] = @P_5, [Gender] = @P_6, [Age] = @P_7, [CurrentWeight] = @P_8, [Link] = @P_9, [Timezone] = @P_10, [Height] = @P_11, [TotalCalorieLostGainPerDay] = @P_12, [TotalCalorieLoseGainPerMonth] = @P_13, [BMI] = @P_14, [WeightCategoryID] = @P_15, [BMR] = @P_16, [ActivityLevelID] = @P_17, [HealthRatingID] = @P_18, [TotalCalorieNeedPerDay] = @P_19, [TargetWeight] = @P_20, [DateTimeAdded] = @P_21, [DateTimeUpdated] = @P_22, [LocationID] = @P_23 FROM [UserProfiles] [base] JOIN [UserProfiles_tracking] [side] ON [base].[UserProfileID] = [side].[UserProfileID] WHERE ([side].[local_update_peer_timestamp] <= @sync_min_timestamp OR @sync_force_write = 1) AND ([base].[UserProfileID] = @P_1); SET @sync_row_count = @@ROWCOUNT;
END